<?php require_once('../Connections/con_gl.php'); ?>
<?php
$getquery = str_replace("+"," ",$_GET[query]);
mysql_select_db($database_con_gl, $con_gl);
$query_rtrans = stripslashes($getquery);
$rtrans = mysql_query($query_rtrans, $con_gl) or die(mysql_error());
$row_rtrans = mysql_fetch_assoc($rtrans);
$totalRows_rtrans = mysql_num_rows($rtrans);

mysql_select_db($database_con_gl, $con_gl);
$query_getcompany = "SELECT * FROM gl_company WHERE id = 1";
$getcompany = mysql_query($query_getcompany, $con_gl) or die(mysql_error());
$row_getcompany = mysql_fetch_assoc($getcompany);
$totalRows_getcompany = mysql_num_rows($getcompany);
?>
<div>
  <table width="100%" border="0" cellspacing="0" cellpadding="2">
    <tr valign="middle">
      <td width="10%" height="115" align="center" style="border:dashed 1px #333333;">LOGO</td>
      <td width="90%" height="115" align="center"><?php echo $row_getcompany['perusahaan']; ?><br>
      <?php echo $row_getcompany['alamat']; ?><br>
      Telp.<?php echo $row_getcompany['telp']; ?> Fax.<?php echo $row_getcompany['fax']; ?> </td>
      <td width="1%" height="115">&nbsp;</td>
    </tr>
	<tr valign="middle">
      <td align="center">&nbsp;</td>
      <td align="center">&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
</div>
  <table width="100%" border="1" cellpadding="4" cellspacing="0" bordercolor="#000000">
    <tr bgcolor="#5A88D5">
      <td width="10%" bgcolor="#CCCCCC"><strong>Tanggal</strong></td>
      <td width="30%" bgcolor="#CCCCCC"><strong>Barang</strong></td>
      <td width="10%" align="center" bgcolor="#CCCCCC"><strong>Masuk</strong></td>
      <td width="10%" align="center" bgcolor="#CCCCCC"><strong>Harga</strong></td>
      <td width="10%" align="center" bgcolor="#CCCCCC"><strong>Total</strong></td>
      <td width="10%" align="center" bgcolor="#CCCCCC"><strong>Keluar</strong></td>
      <td width="10%" align="center" bgcolor="#CCCCCC"><strong>Harga</strong></td>
      <td width="10%" align="center" bgcolor="#CCCCCC"><strong>Total</strong></td>
    </tr>
	<?php $totd =0; $totk = 0; do { ?>
    <tr valign="top" bgcolor="#FFFFFF">
      <td width="10%"><?php echo $row_rtrans['tgl'];?></td>
      <td width="30%"><?php echo $row_rtrans['barang']; ?></td>
      <td width="10%" align="center"><?php if($row_rtrans['jenis']==6) { ?><?php echo $row_rtrans['jumlah']; $jummasuk += $row_rtrans['jumlah'];?> <?php echo $row_rtrans['satuan']; ?><?php }else{ ?> - <?php } ?></td>
      <td width="10%" align="right"><?php if($row_rtrans['jenis']==6) { ?><?php echo number_format($row_rtrans['hargasatuan'],0,',','.').",-"; ?><?php }else{ ?> - <?php } ?></td>
      <td width="10%" align="right"><?php if($row_rtrans['jenis']==6) { ?><?php echo number_format($row_rtrans['total'],0,',','.').",-"; $totmasuk += $row_rtrans['total'];?><?php }else{ ?> - <?php } ?></td>
      <td width="10%" align="center"><?php if($row_rtrans['jenis']==7) { ?>
          <?php echo $row_rtrans['jumlah']; ?> <?php echo $row_rtrans['satuan']; ?>
        <?php }else{ ?>
        -
  <?php } ?></td>
      <td width="10%" align="right"><?php if($row_rtrans['jenis']==7) { ?>
          <?php echo number_format($row_rtrans['hargasatuan'],0,',','.').",-"; ?>
        <?php }else{ ?>
        -
  <?php } ?></td>
      <td width="10%" align="right"><?php if($row_rtrans['jenis']==7) { ?>
          <?php echo number_format($row_rtrans['total'],0,',','.').",-"; $totkeluar +=$row_rtrans['total'];?>
        <?php }else{ ?>
        -
  <?php } ?></td>
    </tr>
	<?php } while ($row_rtrans = mysql_fetch_assoc($rtrans)); ?>
    <tr valign="top">
      <td colspan="4" align="right"><span style="font-weight: bold">Total :</span></td>
      <td align="right"><?php echo number_format($totmasuk,0,',','.').",-";?></td>
      <td colspan="2" align="right"><span style="font-weight: bold">Total :</span></td>
      <td align="right"><?php echo number_format($totkeluar,0,',','.').",-";?></td>
    </tr>
    <tr valign="top">
      <td colspan="6" align="right"><strong>Saldo :</strong> </td>
      <td colspan="2" align="right"><?php $saldo = $totkeluar - $totmasuk; echo number_format($saldo,0,',','.').",-";?></td>
    </tr>
</table>
  <?php
mysql_free_result($getcompany);
?>
